package com.wiken.servicecommon.common;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class R {
    private String message;
    private Map<String, Object> data;
    private Integer code;

    public static R ok() {
        R r = new R();
        return r;
    }

    public static R error(){
        R r = new R();
        return r;
    }

    public R data(String key, Object value){
        this.data = new HashMap<>();
        this.data.put(key, value);

        return this;
    }

    public R data(Map data){
        this.data = data;

        return this;
    }

    public R code(Integer code){
        this.code = code;

        return this;
    }

    public R message(String message) {
        this.setMessage(message);

        return this;
    }

}
